<template>
  <div class="qr-code-wrap">
		<div class="header">
			<img src="./assets/phone-logo.png" class="logoImg">
		</div>
		<div class="content">
			<img src="./assets/text-phone.png" class="textimg">
			<img src="./assets/text-detail-phone.png" class="text-detail">
			<div class="onload">
				<div class="btn" @click="handleLoad" :copy-content="activityChannel">下载拾恋APP</div>
			</div>
		</div>
		<y-deeper-link :activityChannel="activityChannel"/>
	</div>
</template>
<script>
	import Clipboard from 'clipboard';
	import YDeeperLink from '../../components/deeper-link';
	let u = navigator.userAgent;
  export default {
		components: {
			YDeeperLink
		},
    data() {
      return {
				activityChannel: ` `
      }
    },
    methods: {
      // androidIosDownloadLink() {
      //   let Terminal = { 	// 获取终端的相关信息
      //     // 辨别移动终端类型
      //     platform: function () {
      //       let u = navigator.userAgent;
      //       let app = navigator.appVersion;
      //       return {
      //         // android终端或者uc浏览器
      //         android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
      //         // 是否为iPhone或者QQHD浏览器
      //         iPhone: u.indexOf('iPhone') > -1,
      //         // 是否iPad
      //         iPad: u.indexOf('iPad') > -1
      //       };
      //     }(),
      //     // 辨别移动终端的语言：zh-cn、en-us、ko-kr、ja-jp...
      //     language: (navigator.browserLanguage || navigator.language).toLowerCase()
      //   }
      //   // 根据不同的终端，跳转到不同的地址
      //   let theUrl = 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1438503085';
      //   if (Terminal.platform.android) { // 安卓端
      //     theUrl = 'https://sj.qq.com/myapp/detail.htm?apkName=com.yryz.lovelorn';
			// 		// location.href = theUrl;
      //   } else {
      //     if (Terminal.platform.iPhone) { // iPhone端
      //       theUrl = 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1438503085';
      //     }
			// 		// location.href = theUrl;
      //   }
      // },
			handleLoad() {
				if (u.indexOf('iPhone') > -1) {
					window.location.href = 'itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1438503085'
				} else {
					window.location.href = 'https://sj.qq.com/myapp/detail.htm?apkName=com.yryz.lovelorn'
				}
			},
		},
		created() {
			this.activityChannel = `SL-${this.$route.params.id}`
		},
    mounted() {
			let clipboard = new Clipboard('.btn', {
        text: function (trigger) {
          return trigger.getAttribute('copy-content')
        }
      });

      clipboard.on('success', e => {
        // alert('copy success');
      });

      clipboard.on('error', e => {
        // alert('copy error');
      });
		},
  }

</script>
<style scoped>
.qr-code-wrap {
	background: url('./assets/phone-01.jpg') top center no-repeat ;
	background-size: cover;
	width: 100vw;
	height: 100vh;

	& .header {
		width: 11.20rem;
		height: 0.56rem;
		padding-top: 0.5rem;
		padding-left: 0.6rem;

		& .logoImg {
			width: 1.85rem;
			height: 0.82rem;
		}
	}
	& .content {
		margin-top: 2rem;
			width: 100%;
			height: 10rem;
			margin: 0 atuo;
      display: flex;
      flex-direction: column;
      align-items: center;

      & .textimg {
				width: 2.38rem;
					height: 4.9rem;
      }

      & .text {
        font-size: 0.24rem;
        color: #fff;
        margin-top: 0.5rem;
        text-align: center;
      }

      & .text-detail {
        margin-top: 0.5rem;
        width: 3.9rem;
					height: 0.76rem;
      }

      & .onload {
        cursor: pointer;
				width: 4.1rem;
				height: 1.08rem;
				margin-top: 0.64rem;
        & .btn {
					width: 4.10rem;
					height: 1.08rem;
					padding: 0;
					font-size: 0.42rem;
					line-height: 1.08rem;
					transition: none;
					margin-top: 0;
					background: linear-gradient(to right, #f9d378 , #e4408c);
					border-radius: 1rem;
          text-align: center;
					color: #fff;
        }
      }
    }
	
}
</style>
